package by.bsu.rfe.belianko.euniversity.tags;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.tagext.TagSupport;

/**
 * Tag to display the date.
 * 
 * @author Vitali_Belianko
 * 
 */
public class DateTag extends TagSupport {

	private static final long serialVersionUID = 1L;

	/**
	 * Called by the Jsp page's servlet when a start tag is evaluated.Sets date
	 * format.
	 * 
	 * @param SKIP_BODY
	 */
	@Override
	public int doStartTag() {
		Date date = new Date();
		String dateFormat = "dd.MM.yyyy";
		SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
		try {
			pageContext.getOut().write(sdf.format(date));
		} catch (IOException ioe) {
			ioe.getMessage();
		}
		return SKIP_BODY;

	}

}
